// 引入Count的UI组件
import CountUI from "../../components/Count"
import { 
  createIncrement, 
  createDecrement,
  createAsyncIncrement
} from "../../redux/count_action"
// 引入connect用于连接UI组件与redux
import {connect} from "react-redux"

/* -------清晰版的写法，传统写法--------------

// 映射状态
const mapStateToProps = state =>({count: state})

// 映射状态的方法 完整写法
const mapDispatchToProps = dispatch => ({
    jia: data=> dispatch(createIncrement(data)),
    jian: data=> dispatch(createDecrement(data)),
    asyncJia: (data, time)=> dispatch(createAsyncIncrement(data, time))
})

export default connect(mapStateToProps, mapDispatchToProps)(CountUI)
 
*/


/* 简写版 */
export  default connect(
  state =>({count: state}),

  // mapDispatchToProps的简写方式
  // react-redux 帮你把action分发出去
  {
    jia:createIncrement,
    jian:createDecrement,
    asyncJia:createAsyncIncrement,
  }
)(CountUI)




